<#include "macro_.ftl">
package ${packageCode}.${moduleMapperKey}.dao;

import java.util.List;
import java.util.Map;

import com.cardone.common.cache.support.CacheEvictSupport;
import com.cardone.common.dto.PaginationDto;
import ${packageCode}.${moduleMapperKey}.dto.${entityMapper.code}Dto;

/**
 * ${entityMapper.remarks!entityMapper.code}
 *
 * @author ${author!'yaoht'}
 * 
 */
public interface ${entityCode}Dao extends CacheEvictSupport {
	/**
	 * spring bean id
	 */
	String BEAN_ID = "${packageCode}.${moduleMapperKey}.dao.${entityCode}Dao";

		/**
		 * sql标识
		 * 
		 * @author yaoht
		 * 
		 */
		public enum SqlIds {
        /**
	     * 插入
	     */
		insertByCode,
	
		/**
	     * 插入
	     */
		insertByName,
	
		/**
	     * 删除
	     */
		deleteByCode,
	
		/**
	     * 删除
	     */
		deleteByIds,
	
		/**
	     * 更新
	     */
		updateByCode,
	
		/**
	     * 更新
	     */
		updateByIds,
	
		/**
	     * 读取
	     */
		readByCode,
	
		/**
	     * 读取
	     */
		readByName,
	
		/**
	     * 查询
	     */
		findByCode,
	
		/**
	     * 查询
	     */
		findByName;

		/**
		 * 根目录
		 */
		private static final String ROOT = "/${projectCode!}/${moduleMapperKey}/${entityMapper.code?uncap_first}/";

		/**
		 * 标识
		 */
		private final String id;

		/**
		 * sql标识
		 */
		private SqlIds() {
			this.id = SqlIds.ROOT + this.name();
		}

		/**
		 * 获取
		 * 
		 * @return sql标识
		 */
		public String id() {
			return this.id;
		}
	}

	/**
	 * 实体属性
	 * 
	 * @author yaoht
	 * 
	 */
	public enum DtoAttributes {
<#assign ignoreProperties = ',id,code,name,parentId,parentCode,parentName,typeId,typeCode,typeName,orderCode,beginDate,endDate,'>
<#list entityMapper.fieldMapperMap?values as fieldMapper>
<#if !StringUtils.contains(ignoreProperties, (','+fieldMapper.code+','))>
		/**
	     * <@defaultIfBlank str="${fieldMapper.remarks!}" defaultSt="${fieldMapper.code!}"/>
	     */
		${fieldMapper.code},
	
</#if>
</#list>
		/**
		 * 标识
		 */
		ids;
	}

	/**
	 * 插入
	 * 
	 * @param insert${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param insertProperties
	 *            插入属性名集合
	 * 
	 * @return 影响行数
	 */
	int insertByCode(${entityMapper.code}Dto insert${entityMapper.code}, String... insertProperties);
<#if entityMapper.markService>

	/**
	 * 插入
	 * 
	 * @param insert${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 影响行数
	 */
	int insertByCodeOrId(${entityMapper.code}Dto insert${entityMapper.code});

	/**
	 * 插入
	 * 
	 * @param insert${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 影响行数
	 */
	int insertByName(${entityMapper.code}Dto insert${entityMapper.code});
</#if>
	
	/**
	 * 删除
	 * 
	 * @param delete${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param whereAndEqProperties
	 *            条件为等于的属性名集合
	 * 
	 * @return 影响行数
	 */
	int deleteByCode(${entityMapper.code}Dto delete${entityMapper.code}, String... whereAndEqProperties);

<#if entityMapper.markService>
	/**
	 * 删除
	 * 
	 * @param delete${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 影响行数
	 */
	int deleteByCodeOrId(${entityMapper.code}Dto delete${entityMapper.code});
	
	/**
	 * 删除
	 * 
	 * @param delete${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 影响行数
	 */
	int deleteByIds(${entityMapper.code}Dto delete${entityMapper.code});
</#if>

	/**
	 * 更新
	 * 
	 * @param update${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param updateProperties
	 *            更新的属性名集合
	 * 
	 * @param whereAndEqProperties
	 *            条件为等于的属性名集合
	 * 
	 * @return 影响行数
	 */
	int updateByCode(${entityMapper.code}Dto update${entityMapper.code}, String[] updateProperties, String... whereAndEqProperties);

<#if entityMapper.markService>
	/**
	 * 更新
	 * 
	 * @param update${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 影响行数
	 */
	int updateByCodeOrId(${entityMapper.code}Dto update${entityMapper.code});
	
	/**
	 * 更新
	 * 
	 * @param update${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 影响行数
	 */
	int updateByIds(${entityMapper.code}Dto update${entityMapper.code});
</#if>

	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param objectId
	 *            返回对象标识
	 * 
	 * @param read${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param whereAndEqProperties
	 *            条件为等于的属性名集合
	 * 
	 * @return 返回对象
	 */
	<R> R readByCode(Class<R> requiredType, String objectId, ${entityMapper.code}Dto read${entityMapper.code}, String... whereAndEqProperties);
<#if entityMapper.markService>

	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param objectId
	 *            返回对象标识
	 * 
	 * @param read${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 返回对象
	 */
	<R> R readByCodeOrId(Class<R> requiredType, String objectId, ${entityMapper.code}Dto read${entityMapper.code});
	
	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param objectId
	 *            返回对象标识
	 * 
	 * @param read${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 返回对象
	 */
	<R> R readByName(Class<R> requiredType, String objectId, ${entityMapper.code}Dto read${entityMapper.code});
</#if>
	
	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param objectId
	 *            返回对象标识
	 * 
	 * @param readList${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param whereAndEqProperties
	 *            条件为等于的属性名集合
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}对象集合
	 */
	<R> List<R> readListByCode(Class<R> requiredType, String objectId, ${entityMapper.code}Dto readList${entityMapper.code}, String... whereAndEqProperties);

<#if entityMapper.markService>
	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param objectId
	 *            返回对象标识
	 * 
	 * @param readList${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}对象集合
	 */
	<R> List<R> readListByCodeOrId(Class<R> requiredType, String objectId, ${entityMapper.code}Dto readList${entityMapper.code});
	
	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param objectId
	 *            返回对象标识
	 * 
	 * @param readList${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}对象集合
	 */
	<R> List<R> readListByName(Class<R> requiredType, String objectId, ${entityMapper.code}Dto readList${entityMapper.code});
</#if>

	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param find${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param selectProperties
	 *            查询的属性名集合
	 * 
	 * @param whereAndEqProperties
	 *            条件为等于的属性名集合
	 * 
	 * @return 返回对象
	 */
	<P> P findByCode(Class<P> mappedClass, ${entityMapper.code}Dto find${entityMapper.code}, String[] selectProperties, String... whereAndEqProperties);
<#if entityMapper.markService>

	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param find${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 返回对象
	 */
	<P> P findByCodeOrId(Class<P> mappedClass, ${entityMapper.code}Dto find${entityMapper.code});
	
	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param find${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return 返回对象
	 */
	<P> P findByName(Class<P> mappedClass, ${entityMapper.code}Dto find${entityMapper.code});

	/**
	 * 查询
	 * 
	 * @param requiredType
	 *            返回类型
	 * 
	 * @param read${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * @return 返回数据
	 */
	<R> R readByCodeNqId(Class<R> requiredType, ${entityMapper.code}Dto read${entityMapper.code});
</#if>

	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param findList${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @param selectProperties
	 *            查询的属性名集合
	 * 
	 * @param whereAndEqProperties
	 *            条件为等于的属性名集合
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}对象集合
	 */
	<P> List<P> findListByCode(Class<P> mappedClass, ${entityMapper.code}Dto findList${entityMapper.code}, String[] selectProperties, String... whereAndEqProperties);
<#if entityMapper.markService>

	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param findList${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}对象集合
	 */
	<P> List<P> findListByCodeOrId(Class<P> mappedClass, ${entityMapper.code}Dto findList${entityMapper.code});

	/**
	 * 查询
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param findList${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}对象集合
	 */
	<P> List<P> findListByName(Class<P> mappedClass, ${entityMapper.code}Dto findList${entityMapper.code});
<#if entityMapper.markController>

	/**
	 * 分页
	 * 
	 * @param mappedClass
	 *            返回类型
	 * 
	 * @param pagination${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}分页对象
	 */
	<P> PaginationDto<P> paginationByCode(Class<P> mappedClass,
			${entityMapper.code}Dto pagination${entityMapper.code});
			
	/**
	 * 分页
	 * 
	 * @param pagination${entityMapper.code}
	 *            ${entityMapper.remarks!entityMapper.code}对象
	 * 
	 * @return ${entityMapper.remarks!entityMapper.code}分页对象
	 */
	PaginationDto<Map<String, Object>> paginationByName(${entityMapper.code}Dto pagination${entityMapper.code});
</#if>
</#if>
}